package jmine.tec.utils.collection;

import java.io.Serializable;

/**
 * @author takeshi
 * @param <E>
 */
public final class DisjunctionPredicate<E> implements Predicate<E>, Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 552937167843561452L;

    /**
     * 
     */
    private final Predicate<? super E>[] preds;

    /**
     * @param preds os predicados
     */
    public DisjunctionPredicate(final Predicate<? super E>[] preds) {
        this.preds = preds;
    }

    /**
     * @param e the instance
     * @return boolean
     * @see br.com.maps.util.collection.Predicate#matches(java.lang.Object)
     */
    public boolean matches(final E e) {
        for (final Predicate<? super E> predicate : this.preds) {
            if (predicate.matches(e)) {
                return true;
            }
        }
        return false;
    }
}
